package com.liufei1988.sort;

/**
 * 选择排序：每次从未排序的区间找到最小的元素，将其放到已排区间的末尾
 */
public class SelectSort {

    public static void getSelectSort(int[] a,int n){
        if (n<=0) return;
        for (int i=0;i<n-1;i++){
            for (int j=i+1;j<n;j++){
                if (a[i]>a[j]){
                    int tmp=a[i];
                    a[i]=a[j];
                    a[j]=tmp;
                }
            }
            for (int s:a){
                System.out.print(s+" ");
            }
            System.out.println();
        }

    }

    public static void main(String[] args) {
        int[] a={10,20,9,30,8,22,11};
        getSelectSort(a,a.length);
    }
}
